package com.mall.common.util;

import java.util.Date;
import java.util.UUID;

import org.apache.commons.lang.math.RandomUtils;

/**
 * 工具类 - 编号生成
 */
public class SerialNumberUtil {

	public static final long SMS_SN_FIRST = 1000L;// 短信流水号起始数
	public static final long SMS_SN_STEP = 1L;// 短信流水号步长
	
	/**
	 * 短信编号
	 * @return
	 */
	public static String buildSmsMessageSn() {
		String random = String.valueOf(RandomUtils.nextInt(1000));
		while(random.length() < 3) {
			random = "0" + random;
		}
		return DateHelper.date2String(new Date(), "yyyyMMddHHmmssSSS") + random;
	}
	
	/**
	 * 生成令牌，防止重复提交
	 * @return
	 */
	public synchronized static String buildTokenSn() {
		String uuid = UUID.randomUUID().toString();
		return uuid;
	}
	
}